﻿@using Smartstore.Admin.Models.Messages
@using Smartstore.Net.Mail

@model EmailAccountModel

<div asp-validation-summary="All"></div>
<input asp-for="Id" type="hidden" />

<div class="adminContent">
    <div class="adminRow">
        <div class="adminTitle">
            <smart-label asp-for="Email" />
        </div>
        <div class="adminData">
            <input asp-for="Email" />
            <span asp-validation-for="Email"></span>
        </div>
    </div>
    <div class="adminRow">
        <div class="adminTitle">
            <smart-label asp-for="DisplayName" />
        </div>
        <div class="adminData">
            <input asp-for="DisplayName" />
            <span asp-validation-for="DisplayName"></span>
        </div>
    </div>
    <div class="adminRow">
        <div class="adminTitle">
            <smart-label asp-for="Host" />
        </div>
        <div class="adminData">
            <input asp-for="Host" />
            <span asp-validation-for="Host"></span>
        </div>
    </div>
    <div class="adminRow">
        <div class="adminTitle">
            <smart-label asp-for="Port" />
        </div>
        <div class="adminData">
            <editor asp-for="Port" />
            <span asp-validation-for="Port"></span>
        </div>
    </div>
    <div class="adminRow">
        <div class="adminTitle">
            <smart-label asp-for="Username" />
        </div>
        <div class="adminData">
            <input asp-for="Username" />
            <span asp-validation-for="Username"></span>
        </div>
    </div>
    <div class="adminRow">
        <div class="adminTitle">
            <smart-label asp-for="Password" />
        </div>
        <div class="adminData">
            <editor asp-for="Password" attr-value='(Model.Password.HasValue(), Model.Password)' class="form-control" />
            <span asp-validation-for="Password"></span>
        </div>
    </div>
    <div class="adminRow">
        <div class="adminTitle">
            <smart-label asp-for="MailSecureOption" />
        </div>
        <div class="adminData">
            <select asp-for="MailSecureOption" asp-items="Html.GetLocalizedEnumSelectList(typeof(MailSecureOption))"></select>
            <span asp-validation-for="MailSecureOption"></span>
        </div>
    </div>
    <div class="adminRow">
        <div class="adminTitle">
            <smart-label asp-for="UseDefaultCredentials" />
        </div>
        <div class="adminData">
            <input asp-for="UseDefaultCredentials" />
            <span asp-validation-for="UseDefaultCredentials"></span>
        </div>
    </div>
    <div class="adminRow">
        <div class="adminTitle">
            <smart-label asp-for="IsDefaultEmailAccount" />
        </div>
        <div class="adminData">
            <input asp-for="IsDefaultEmailAccount" />
            <span asp-validation-for="IsDefaultEmailAccount"></span>
        </div>
    </div>
    @if (Model.Id > 0)
    {
        <div class="adminRow">
            <div class="admin-config-group">
                <div class="title">@T("Admin.Configuration.EmailAccounts.SendTestEmail")</div>
            </div>
        </div>
        <div class="adminRow">
            <div class="adminTitle">
                <smart-label asp-for="SendTestEmailTo" />
            </div>
            <div class="adminData">
                <div class="input-group">
                    <input asp-for="SendTestEmailTo" type="email" />
                    <div class="input-group-append">
                        <button type="submit" name="sendtestemail" value="sendtestemail" class="btn btn-secondary">
                            <i class="far fa-share"></i>
                            <span>@T("Admin.Configuration.EmailAccounts.SendTestEmail.Button")</span>
                        </button>
                    </div>
                </div>
                <span asp-validation-for="SendTestEmailTo"></span>
            </div>
        </div>
    }
</div>

<p sm-if="Model.TestEmailShortErrorMessage.HasValue()">
    <div class="alert alert-danger">@Model.TestEmailShortErrorMessage</div>
    <pre>@Model.TestEmailFullErrorMessage</pre>
</p>